<?php
namespace app\admin\model;
use think\Db;
class Users extends Base
{


    /**会员封停
     */
    public function stopUser($id)
    {
        $row = Db::table('users')->where("user_id = $id")->update(['user_state' => 1]);
        if ($row > 0) {
            return 0; 
        } else {
            return 1;
        }


    }

    /**会员解封
     */
    public function startUser($id)
    {
        $row = Db::table('users')->where("user_id = $id")->update(['user_state' => 0]);
        if ($row > 0) {
            return "操作成功";
        } else {
            return "你的操作太骚，系统不予识别";
        }
    }

/**
*会员订单查找
 */
  public function userOrderList(){
      
  }















    public function setVip($id, $time)
    {
        if ($time == 1) {
            $data = [
                'uid' => "$id",
                'time' => time(),
                'endtime' => strtotime('+1 month')
            ];
        } elseif ($time == 2) {
            $data = [
                'uid' => "$id",
                'time' => time(),
                'endtime' => strtotime('+2 month')
            ];
        } elseif ($time == 3){
            $data = [
                'uid' => "$id",
                'time' => time(),
                'endtime' => strtotime('+3 month')
            ];

        }
       $row = $this->add('time',$data);
        if($row>0){
            $jg = Db::table('users')->where('user_id',$id)->update(['user_grade' => 1]);
        }
        if($jg>0){
            return 1;
        }else{
            return 2;
        }
    }






}